package com.liuqianfei.markme.render;

import com.liuqianfei.markme.IRender;
import com.liuqianfei.markme.Renderer;
import com.liuqianfei.markme.core.Configuration;
import com.liuqianfei.markme.core.Token;
import com.liuqianfei.markme.rules.Environment;

import java.util.List;

/**
 * @author liuqianfei
 */
public class ImageRender implements IRender
{
    @Override
    public String render(List<Token> tokens, int idx, Configuration configuration, Environment env, Renderer renderer)
    {
        Token token = tokens.get(idx);

        // "alt" attr MUST be set, even if empty. Because it's mandatory and
        // should be placed on proper position for tests.
        //
        // Replace content with actual value
        token.attrs.put("alt", renderer.renderInlineAsText(token.children, configuration, env));

        return renderer.renderToken(tokens, idx, configuration);
    }
}
